
#include <bur/plctypes.h>

#ifdef _DEFAULT_INCLUDES
	#include <AsDefault.h>
#endif

#include "RTInfo.h"
#include "camera_driver.h"
#include "image_getter.h"
#include <string.h>

void _INIT ProgramInit(void)
{
	// RTInfo
	INIT_RT_INFO;
	
	// the ImageGetter_t class as a singleton in this POU, instance define and initialized in image_getter.c
	pImageGetter = ImageGetter_GetInstance();
	
	// low level camera IO initialization
	int i = 0;
	for (i = 0; i < CAM_NUM; i++)
	{
		Camera[i].State = VI_INIT;
		// if EPL SDO r/w is necessary, define the necessary FB and assign them to each camera IO structure 
		Camera[i].FB.SDOWrite = &EplSDOWrite_0[i];
		Camera[i].FB.SDORead = &EplSDORead_0[i];
		
		// something that should be executed in every init routine
		Camera[i].Internal.OldAcceptedAcquisitionCnt = Camera[i].Status.AcceptedAcquisitionCnt;
		Camera[i].Internal.OldCompletedAcquisitionCnt = Camera[i].Status.CompletedAcquisitionCnt;
		Camera[i].Internal.OldFailedAcquisitionCnt = Camera[i].Status.FailedAcquisitionCnt;
		
		// link between the [global camera control PV] & [local camera IO PV] 
		LinkCameraDriver(&gCamera[i], &Camera[i]);
	}
}
